package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.Destination;
import cn.wolfcode.wolf2w.domain.Region;
import cn.wolfcode.wolf2w.domain.Spot;
import cn.wolfcode.wolf2w.domain.SpotCatalog;
import cn.wolfcode.wolf2w.service.IDestinationService;
import cn.wolfcode.wolf2w.service.IRegionService;
import cn.wolfcode.wolf2w.service.ISpotCatalogService;
import cn.wolfcode.wolf2w.service.ISpotService;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/spotCatalog")
public class SpotController {
    @Autowired
    private ISpotCatalogService spotCatalogService;
    @Autowired
    private ISpotService spotService;

    @GetMapping("/list")
    public Object list(){
        return JsonResult.success(spotCatalogService.listAll());
    }

    @GetMapping("/getCatalog")
    public Object getCatalog(String id){
//        Spot spot = spotService.get(id);
        Spot spot =  spotService.queryByCatlogId(id);
        SpotCatalog catalog = spotCatalogService.get(spot.getCatlogId());
        spot.setSpotCatalogs(catalog);
        return JsonResult.success(spot);
    }
}
